<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../../component/pear/css/pear.css"/>
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label">代办标题</label>
                <div class="layui-input-block">
                    <input type="text" name="doTitle" lay-verify="required|title" maxlength="80"
                           autocomplete="off"
                           placeholder="请输入代办标题"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">代办描述</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入代办描述" name="doContent" class="layui-textarea" autocomplete="off" maxlength="80"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">计划日期</label>
                <div class="layui-input-block">
                    <input type="text" id="lastDate" name="lastDate" lay-verify="required|title" autocomplete="off"
                           placeholder="请输入最迟完成时间"
                           class="layui-input">
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>

<script>
    layui.use(['form', 'jquery', 'laytpl', 'laydate', 'easyAdmin'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let easyAdmin = layui.easyAdmin;
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#lastDate', //指定元素
            type: 'date'
        });

        form.on('submit(save)', function (data) {
            easyAdmin.http({
                url: '/ext/do',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.success) {
                        layer.msg(result.msg,
                            {
                                icon: 1,
                                time: 1000,
                                area: ['100px', '80px'],
                                content: "新增成功"
                            }
                            , function () {
                                parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                                parent.layui.table.reload("table");
                            });
                    } else {
                        layer.msg(result.msg,
                            {icon: 2, time: 1000, area: ['260px', '80px']}
                        );
                    }
                }
            })
            return false;
        });
    })
</script>
<script>
</script>
</body>
</html>
